package v1

import (
	"dev-assistant-backend/api"

	"github.com/gogf/gf/v2/frame/g"
)

//////////////////////////////////////////////////////////

// CreateReq 创建用户请求
type CreateReq struct {
	g.Meta `path:"/user/create" method:"post" tags:"user management" summary:"create user"`
	api.BaseHeader
	Name     string `json:"name"     v:"required|length:2,30#用户名不能为空|用户名长度应当在:min到:max之间"`
	Email    string `json:"email"    v:"required|email#邮箱不能为空|邮箱格式不正确"`
	Phone    string `json:"phone"`
	Password string `json:"password" v:"required|length:8,50#密码不能为空|密码长度应当在8到50之间"`
	Role     int    `json:"role"     v:"in:0,1,2#角色值不正确"`
}

// CreateRes 创建用户响应
type CreateRes struct {
	g.Meta `mime:"application/json"`
	ID     string `json:"id"`
	Name   string `json:"name"`
	Email  string `json:"email"`
	Phone  string `json:"phone"`
	Role   int    `json:"role"`
	Status int    `json:"status"`
}

func NewCreateRes(
	id string,
	name string,
	email string,
	phone string,
	role int,
	status int,
) *CreateRes {
	return &CreateRes{
		ID:     id,
		Name:   name,
		Email:  email,
		Phone:  phone,
		Role:   role,
		Status: status,
	}
}

//////////////////////////////////////////////////////////

type LoginReq struct {
	g.Meta `path:"/user/login" method:"post" tags:"user management" summary:"login"`
	api.BaseHeader
	Email    string `json:"email"    v:"required|email#邮箱不能为空|邮箱格式不正确"`
	Password string `json:"password" v:"required|length:8,50#密码不能为空|密码长度应当在8到50之间"`
}

type LoginRes struct {
	g.Meta `mime:"application/json"`
	ID     string `json:"id"`
	Name   string `json:"name"`
	Email  string `json:"email"`
	Phone  string `json:"phone"`
	Role   int    `json:"role"`
	Status int    `json:"status"`
}

func NewLoginRes(
	id string,
	name string,
	email string,
	phone string,
	role int,
	status int,
) *LoginRes {
	return &LoginRes{
		ID:     id,
		Name:   name,
		Email:  email,
		Phone:  phone,
		Role:   role,
		Status: status,
	}
}
